package top.datacluster.basic.algorithm.leetcode.stack;

import java.util.Stack;

public class LeetCode1568 {

    private Stack<Integer> data = new Stack<>();

    private Stack<Integer> min = new Stack<>();

    /** initialize your data structure here. */
    public LeetCode1568() {

    }

    public void push(int x) {
        data.push(x);
        if (min.isEmpty()){
            min.push(x);
        }else{
            if (x > min.peek()){
                min.push(min.peek());
            }else{
                min.push(x);
            }
        }
    }

    public void pop() {
        data.pop();
        min.pop();
    }

    public int top() {
        return data.peek();
    }

    public int min() {
        return min.peek();
    }
}
